package com.test.rest.client;

import java.util.Iterator;

import org.apache.cxf.jaxrs.client.WebClient;

import com.test.rest.bean.Book;
import com.test.rest.bean.Category;

public class Client {

	public static void main(String[] args) {
		
		WebClient client = WebClient.create("http://localhost:9000/");
		
		Category category = client.path("categoryservice/category/001").accept("application/xml").get(Category.class);
		
		System.out.println(category.getCategoryName());
		System.out.println(category.getCategoryId());
		
		
		client = WebClient.create("http://localhost:9000/");
		
		category = client.path("categoryservice/category/002/books").accept("application/xml").get(Category.class);
		
		Iterator<Book> iterator = category.getBooks().iterator();
		
		while (iterator.hasNext()) {
			Book book = iterator.next();
			System.out.println(book.getBookName());
			System.out.println(book.getBookNumber());
		}
		
	}
	
}
